//
//  CouserUserlevelView.m
//  ShowYork
//
//  Created by hxh on 2020/8/28.
//  Copyright © 2020 hxh. All rights reserved.
//

#import "LessonUserlevelView.h"

@interface LessonUserlevelView ()
@property (nonatomic,strong)UIView *containView;

@end

@implementation LessonUserlevelView


- (instancetype)init{
    if (self = [super init]) {
        [self setUI];
    }
    return self;
}

- (void)setUI{
    
    self.frame = CGRectMake(0, kNavBarHeight, kScreenW, kScreenH);

    [[UIApplication sharedApplication].keyWindow addSubview:self];
    
    self.containView = [[UIView alloc]init];
    
    [self addSubview:self.containView];
    
    [self.containView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self);
        make.left.right.equalTo(self);
        make.height.mas_equalTo(44 * 3);
    }];
    
    NSArray *titleArr = @[@"高一",@"高二",@"高三"];
    
    UIView *lastView = nil;
    
    for (int i = 0; i < titleArr.count; i++) {
        UILabel *lb = [[UILabel alloc]init];
        lb.text = titleArr[i];
        lb.textColor = RGBA(51, 51, 51, 1);
        lb.font = font(14);
        [self.containView addSubview:lb];
        UIImageView *imgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"course_tick"]];
        imgView.hidden = i != 2;
        [self.containView addSubview:imgView];
        
        if (!lastView) {
            [lb mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.containView);
                make.height.mas_equalTo(44);
                make.left.equalTo(self.containView).offset(16);
            }];
        }else{
            [lb mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(lastView.mas_bottom);
                make.height.mas_equalTo(44);
                make.left.equalTo(self.containView).offset(16);
            }];
        }
        [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(lb);
            make.right.equalTo(self.containView).offset(-16);
        }];
        lastView = lb;
    }
    
    self.containView.backgroundColor = [UIColor whiteColor];

    
    [self.containView layoutIfNeeded];
    
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.containView.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(14, 14)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = self.containView.bounds;
    maskLayer.path = maskPath.CGPath;
    self.containView.layer.mask = maskLayer;
}

- (void)removeView{
    self.hidden = YES;
}

- (void)show{
    self.hidden = NO;
    
    
//
  
}
@end
